package 设计模式.行为模式.模板模式;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lchenglong
 * @date 2024/1/26
 */
@RestController
@RequestMapping("login")
public class LoginController {
    @Autowired
    private LoginFactory loginFactory;

    @RequestMapping(value = "login")
    public Result login(String username,String content,Integer loginType){
        LoginTypeEnum loginTypeEnum = LoginTypeEnum.getEnumByType(loginType);
        Assert.notNull(loginTypeEnum,"赞助不支持该方式登录");
        LoginTemplate loginService = loginFactory.getLoginService(loginTypeEnum);
        return loginService.login(username,content);
    }

}
